﻿using System;
using System.Web;
using G = IU.Contabilidad.ContabilidadGlobal;
using ModuloSoporte;

namespace IU.Generico.Pages
{
    public class LoggedPage : BasePageSessionExpire
    {
        protected override string Redirect
        {
            get
            {
                return "~/Default.aspx";
            }
        }

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }
    }

    public class LoggedComponentPage : BasePageSessionExpire
    {
        protected override string Redirect
        {
            get
            {
                return "~/SessionTimeout.aspx";
            }
        }

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (string.IsNullOrEmpty(Global.Usuario))
            {
                HttpContext.Current.Response.Redirect(Redirect);
            }
        }
    }

    public class AdminSubPage : BasePageSessionExpire
    {
        protected override string Redirect
        {
            get
            {
                return "~/SessionTimeout.aspx";
            }
        }

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string redirect = "";
            try
            {
                if (string.IsNullOrEmpty(Global.Usuario))
                {
                    HttpContext.Current.Response.Redirect("~/SessionTimeout.aspx");
                }
                else
                {
                    redirect = null;
                }
            }
            catch
            {
                redirect = "SessionTimeout.aspx";
            }

            if(!string.IsNullOrEmpty(redirect))
                Response.Redirect(redirect);
        }
    }
}
